package cn.shangqizhenshuai.util;

import sun.misc.IOUtils;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Util {
    //首字母大写
    public static String upperCase(String str) {
        char[] ch = str.toCharArray();
        if (ch[0] >= 'a' && ch[0] <= 'z') {
            ch[0] = (char) (ch[0] - 32);
        }
        return new String(ch);
    }
    //去除特殊字符
    public static String sub(String s){
        String regEx="[_`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]";
//        return s.replaceAll("[^a-zA-Z_\u4e00-\u9fa5]", "");

        Pattern p   =   Pattern.compile(regEx);
        Matcher m   =   p.matcher(s);
        return   m.replaceAll("").trim();

    }
    //首字母转小写
    public static String toLowerCaseFirstOne(String s){
        if(Character.isLowerCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
    }

}
